﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using JXT.PrimaryKey.Batman.Validation;
using JXT.PrimaryKey.Batman.Domain.UserSystem.Models;

namespace JXT.PrimaryKey.Batman.Domain.UserSystem.Validation
{
    public class SystemUserValidator : IValidator<SystemUser>
    {
        public ValidationResult Validate(SystemUser entity)
        {
            ValidationErrorCollection errors = new ValidationErrorCollection();
            if (String.IsNullOrEmpty(entity.Name))
                errors.Add("Name", entity.Name, "name can not be null or empty!");
            if (String.IsNullOrEmpty(entity.Summary))
                errors.Add("Summary", entity.Summary, "summary can not be null or empty!");
            if (String.IsNullOrEmpty(entity.RegisterIp))
                errors.Add("RegisterIp", entity.RegisterIp, "registerip can not be null or empty!");
            return new ValidationResult(errors);
        }
    }
}
